<template>
<div>
  <van-nav-bar title="绑定住院号" left-text="返回"
               left-arrow  @click-left="back"/>
  <div>
    <div>
     <h4>请选择要绑定的就诊人</h4>
    </div>
    <van-cell-group inset>
      <van-cell v-for="p in patients" style="background-color: ghostwhite;border-radius: 10px;margin-top: 20px" @click="tz(p)">
        <template #title>
          <label style="font-weight: bold;font-size: 20px">{{p.name}}</label>
          <label style="border-radius: 10px;background-color: gainsboro;padding: 5px;margin-left: 20px">{{p.type}}</label>
        </template>
        <template style="margin-top: 10px" #label>
          <label>{{p.cardno}}</label>
        </template>
      </van-cell>
    </van-cell-group>
  </div>
</div>
</template>

<script setup>
import {ref,onMounted} from "vue";
import axios from "axios";
import {useStore} from 'vuex'
import {useRouter} from "vue-router";

const store=useStore()
const router = useRouter()
const patients=new ref([])

const ck=ref(true)
onMounted(()=>{
  //请求接口 axios
  axios.get("patient/my?uid="+store.state.user.id).then(res=>{
    if(res.data.code==0){
      patients.value=res.data.data;
    }
  });
})
const back=()=>{
  history.back();
}
const tz = (obj) => {
  store.commit("setBindpatient",obj);
  router.push("/addhospitalized");
}
</script>

<style scoped>

</style>
